Skip to content

Make simplify php-check-html-for-indentation and deprecate multi-modes support#742

Open
zonuexe wants to merge 5 commits into
masterfrom
refactor/switch-html-template-major-mode
Open

Make simplify php-check-html-for-indentation and deprecate multi-modes support#742
zonuexe wants to merge 5 commits into
masterfrom
refactor/switch-html-template-major-mode

Conversation

@zonuexe

@zonuexe zonuexe commented Apr 10, 2023

Copy link
Copy Markdown
Member

We no longer supports mumamo, mmm-mode and multi-mode.

@zonuexe zonuexe force-pushed the refactor/switch-html-template-major-mode branch from b791053 to c30d0a3 Compare April 10, 2023 18:46
@zonuexe zonuexe force-pushed the refactor/switch-html-template-major-mode branch from c30d0a3 to b420204 Compare April 23, 2023 14:48
…s support

We no longer supports mumamo, mmm-mode and multi-mode.
@zonuexe zonuexe force-pushed the refactor/switch-html-template-major-mode branch from b420204 to 4ccdad1 Compare July 9, 2026 19:59
zonuexe added 4 commits July 10, 2026 05:09
Explain that php-mode targets pure PHP scripts and that files mixing HTML
and PHP are handled by php-html-template-major-mode, how php-mode-maybe
chooses the major mode, and the php-mode-warn-if-html-template prompt.
php-check-html-for-indentation calls php-buffer-has-html-tag on every
line indentation, and the function scans the whole buffer from the start.
For a plain PHP file with no HTML tag it always scans to the end, so on a
large file most of the per-line indentation time is spent re-scanning.

Cache the result by buffer-chars-modified-tick and recompute it only
after the buffer text changes. On tcpdf.php (8513 lines, 294 KB) a warm
php-cautious-indent-line drops from about 3.85 ms to 0.26 ms, and the
result still tracks HTML tags added or removed by later edits.
php-check-html-for-indentation returned nil in a polymode buffer, which
made php-cautious-indent-line and -region skip c-indent entirely, so PHP
chunks of poly-php-html-mode were never indented.  In a polymode buffer
php-mode only ever indents its own PHP chunks, so return non-nil and let
indentation proceed.

While here: make php-warned-bad-indent buffer-local and set it
consistently so a warning in one buffer does not silence others, fix the
"seems to contains" prompt grammar, and give php-check-html-for-indentation
a docstring describing its return value.
Add tests covering the two behaviours reworked here: PHP chunks of a
PHP-in-HTML polymode must indent (a regression fix), and a PHP file that
contains HTML must derive to php-html-template-major-mode.

Install polymode and web-mode as development dependencies, and install
dev dependencies in the test target so the tests run in CI.  The poly
test defines its innermode inline rather than depending on the poly-php
package, because poly-php requires php-mode and would install a released
copy from an archive that shadows the php-mode under test.  Both tests
skip when their optional package is unavailable.
@zonuexe zonuexe force-pushed the refactor/switch-html-template-major-mode branch from fc16a36 to fd4fe5b Compare July 9, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant